﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ChartDirector;

namespace CSharpChartExplorer
{
    public class FrmZoomScrollDemo : System.Windows.Forms.Form
    {
        // Data arrays for the scrollable / zoomable chart.
        private DateTime[] timeStamps;
        private double[] dataSeriesA;
        private double[] dataSeriesB;
        private double[] dataSeriesC;

        // The earliest date and the duration in seconds for horizontal scrolling
        private DateTime minDate;
        private double dateRange;

        // The vertical range of the chart for vertical scrolling
        private double maxValue;
        private double minValue;

        // The current visible duration of the view port in seconds
        private double currentDuration = 360 * 86400;
        // In this demo, the maximum zoom-in is set to 10 days
        private double minDuration = 10 * 86400;

        // Will set to true at the end of initialization
        private bool hasFinishedInitialization = false;

        //
        // Controls in the form
        // *** Automatically generated by Windows Form Designer ***
        //
        private System.Windows.Forms.Label topLabel;
        private System.Windows.Forms.Panel leftPanel;
        private System.Windows.Forms.RadioButton pointerPB;
        private System.Windows.Forms.RadioButton zoomInPB;
        private System.Windows.Forms.RadioButton zoomOutPB;
        private System.Windows.Forms.Label zoomModeLabel;
        private System.Windows.Forms.Panel zoomModePanel;
        private System.Windows.Forms.RadioButton xZoomPB;
        private System.Windows.Forms.RadioButton xyZoomPB;
        private System.Windows.Forms.Label startDateLabel;
        private System.Windows.Forms.DateTimePicker startDate;
        private System.Windows.Forms.Label durationLabel;
        private System.Windows.Forms.ComboBox duration;
        private System.Windows.Forms.Label separatorLine;
        private ChartDirector.WinChartViewer winChartViewer1;
        private System.Windows.Forms.HScrollBar hScrollBar1;
        private System.Windows.Forms.VScrollBar vScrollBar1;
        private System.Windows.Forms.Panel filler;
        private System.Windows.Forms.ToolTip toolTip;
        private System.ComponentModel.IContainer components = null;

        public FrmZoomScrollDemo()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
        }

        /// <summary>
        /// Clean up any resources used.
        /// *** Automatically generated by Windows Form Designer ***
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        /// <summary>
        /// Form Load event handler - initialize the form
        /// </summary>
        private void FrmZoomScrollDemo_Load(object sender, System.EventArgs e)
        {
            // Read in the data
            loadData();

            // In this demo, we obtain the horizontal scroll range from the actual data.
            minDate = timeStamps[0];
            dateRange = timeStamps[timeStamps.Length - 1].Subtract(minDate).TotalSeconds;

            // Set the date range of the date picker
            startDate.MinDate = minDate;
            startDate.MaxDate = minDate.AddSeconds(dateRange);

            // Set the winChartViewer to reflect the visible and minimum duration
            winChartViewer1.ZoomInWidthLimit = minDuration / dateRange;
            winChartViewer1.ViewPortWidth = currentDuration / dateRange;
            winChartViewer1.ViewPortLeft = 1 - winChartViewer1.ViewPortWidth;

            // Initially choose the pointer mode (drag to scroll mode)
            pointerPB.Checked = true;
            xZoomPB.Checked = true;

            // Can update chart now
            hasFinishedInitialization = true;
            winChartViewer1.updateViewPort(true, true);
        }

        /// <summary>
        /// Load the data
        /// </summary>
        private void loadData()
        {
            // In this demo, we allow scrolling for the last 5 years.
            DateTime lastDate = DateTime.Now.Date;
            DateTime firstDate = DateTime.Now.Date.AddYears(-5);

            // The initial view port is to show 1 year of data.
            currentDuration = lastDate.Subtract(DateTime.Now.Date.AddYears(-1)).TotalSeconds;

            //
            // Get the data and stores them in a memory buffer for fast scrolling / zooming. In 
            // this demo, we just use a random number generator. In practice, you may get the data
            // from a database or XML or by other means. (See the ChartDirector documentation on 
            // "Using Data Sources with ChartDirector" if you need some sample code on how to read
            // data from database to array variables.)
            //

            // Set up random number generator
            RanTable r = new RanTable(127, 4, lastDate.Subtract(firstDate).Days + 1);
            r.setDateCol(0, firstDate, 86400);
            r.setCol(1, 150, -10, 10);
            r.setCol(2, 200, -10, 10);
            r.setCol(3, 250, -10, 10);

            // Read random data into the data arrays
            timeStamps = Chart.NTime(r.getCol(0));
            dataSeriesA = r.getCol(1);
            dataSeriesB = r.getCol(2);
            dataSeriesC = r.getCol(3);
        }

        /// <summary>
        /// CheckChanged event for the pointerPB.
        /// </summary>
        private void pointerPB_CheckedChanged(object sender, System.EventArgs e)
        {
            pointerPB.BackColor = pointerPB.Checked ? Color.PaleGreen : pointerPB.Parent.BackColor;
            if (pointerPB.Checked)
                winChartViewer1.MouseUsage = WinChartMouseUsage.ScrollOnDrag;
        }

        /// <summary>
        /// CheckChanged event for the zoomInPB.
        /// </summary>
        private void zoomInPB_CheckedChanged(object sender, System.EventArgs e)
        {
            zoomInPB.BackColor = zoomInPB.Checked ? Color.PaleGreen : zoomInPB.Parent.BackColor;
            if (zoomInPB.Checked)
                winChartViewer1.MouseUsage = WinChartMouseUsage.ZoomIn;
        }

        /// <summary>
        /// CheckChanged event for the zoomOutPB.
        /// </summary>
        private void zoomOutPB_CheckedChanged(object sender, System.EventArgs e)
        {
            zoomOutPB.BackColor = zoomOutPB.Checked ? Color.PaleGreen : zoomOutPB.Parent.BackColor;
            if (zoomOutPB.Checked)
                winChartViewer1.MouseUsage = WinChartMouseUsage.ZoomOut;
        }

        /// <summary>
        /// CheckChanged event for the xZoomPB. Sets X-Zoom / Y-Axis auto-scaled mode.
        /// </summary>
        private void xZoomPB_CheckedChanged(object sender, System.EventArgs e)
        {
            xZoomPB.BackColor = xZoomPB.Checked ? Color.PaleGreen : xZoomPB.Parent.BackColor;
            if (xZoomPB.Checked)
            {
                // Horizontal zooming and scrolling only
                winChartViewer1.ZoomDirection = WinChartDirection.Horizontal;
                winChartViewer1.ScrollDirection = WinChartDirection.Horizontal;

                // Viewport is always unzoomed as y-axis is auto-scaled
                winChartViewer1.ViewPortTop = 0;
                winChartViewer1.ViewPortHeight = 1;

                // Update chart to auto-scale axis
                if (hasFinishedInitialization)
                    winChartViewer1.updateViewPort(true, false);
            }
        }

        /// <summary>
        /// CheckChanged event for the xZoomPB. Set XY-Zoom mode.
        /// </summary>
        private void xyZoomPB_CheckedChanged(object sender, System.EventArgs e)
        {
            xyZoomPB.BackColor = xyZoomPB.Checked ? Color.PaleGreen : xyZoomPB.Parent.BackColor;
            if (xyZoomPB.Checked)
            {
                // Horizontal and Vertical zooming and scrolling
                winChartViewer1.ZoomDirection = WinChartDirection.HorizontalVertical;
                winChartViewer1.ScrollDirection = WinChartDirection.HorizontalVertical;
            }
        }

        /// <summary>
        /// ValueChanged event for startDate control. Updates WinChartViewer ViewPortLeft to the 
        /// selected starting date.
        /// </summary>
        private void startDate_ValueChanged(object sender, System.EventArgs e)
        {
            if (hasFinishedInitialization)
            {
                winChartViewer1.ViewPortLeft = startDate.Value.Subtract(minDate).TotalSeconds / dateRange;
                winChartViewer1.updateViewPort(true, false);
            }
        }

        /// <summary>
        /// SelectedIndexChanged event for the duration control.
        /// </summary>
        private void duration_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            validateDuration();
        }

        /// <summary>
        /// KeyPress event for the duration control. Validate duration when "Enter" key pressed.
        /// </summary>
        private void duration_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                validateDuration();
        }

        /// <summary>
        /// Leave event for the duration control.
        /// </summary>
        private void duration_Leave(object sender, System.EventArgs e)
        {
            validateDuration();
        }

        /// <summary>
        /// Validate duration and updates WinChartViewer.ViewPortWidth to reflect the duration.
        /// </summary>
        private void validateDuration()
        {
            // Parse the duration text
            double newDuration = 0;
            try { newDuration = Double.Parse(duration.Text) * 86400; }
            catch { }

            // Duration too short or not numeric?
            if (newDuration < minDuration)
                newDuration = minDuration;

            if (hasFinishedInitialization && (newDuration != currentDuration))
            {
                // Set the ViewPortWidth according to the new duration
                currentDuration = newDuration;
                winChartViewer1.ViewPortWidth = newDuration / dateRange;
                winChartViewer1.updateViewPort(true, false);
            }
        }

        /// <summary>
        /// Horizontal ScrollBar ValueChanged event handler
        /// </summary>
        private void hScrollBar1_ValueChanged(object sender, System.EventArgs e)
        {
            if (hasFinishedInitialization)
            {
                // Set the view port based on the scroll bar
                winChartViewer1.ViewPortLeft = ((double)(hScrollBar1.Value - hScrollBar1.Minimum))
                    / (hScrollBar1.Maximum - hScrollBar1.Minimum);

                // Update the chart display without updating the image maps. (We can delay updating
                // the image map until scrolling is completed and the chart display is stable.)
                winChartViewer1.updateViewPort(true, false);
            }
        }

        /// <summary>
        /// Vertical ScrollBar ValueChanged event handler
        /// </summary>
        private void vScrollBar1_ValueChanged(object sender, System.EventArgs e)
        {
            if (hasFinishedInitialization)
            {
                // Set the view port based on the scroll bar
                winChartViewer1.ViewPortTop = ((double)(vScrollBar1.Value - vScrollBar1.Minimum))
                    / (vScrollBar1.Maximum - vScrollBar1.Minimum);

                // Update the chart display without updating the image maps. (We can delay updating
                // the image map until scrolling is completed and the chart display is stable.)
                winChartViewer1.updateViewPort(true, false);
            }
        }

        /// <summary>
        /// The MouseEntered handler for the ChartViewer. In this demo, we delay creating the image 
        /// map until the mouse actually enters the chart. This avoids creating unnecessary image
        /// maps while the chart is still scrolling.
        /// </summary>
        private void winChartViewer1_MouseEnter(object sender, System.EventArgs e)
        {
            updateImageMap(winChartViewer1);
        }

        /// <summary>
        /// ClickHotSpot event handler. In this demo, we just list out the hot spot information in 
        /// a pop up dialog.
        /// </summary>
        private void winChartViewer1_ClickHotSpot(object sender, ChartDirector.WinHotSpotEventArgs e)
        {
            // We show the pop up dialog only when the mouse action is not in zoom-in or zoom-out mode.
            if ((winChartViewer1.MouseUsage != WinChartMouseUsage.ZoomIn)
                && (winChartViewer1.MouseUsage != WinChartMouseUsage.ZoomOut))
                new ParamViewer().Display(sender, e);
        }

        /// <summary>
        /// The ViewPortChanged event handler. This event occurs when the user changes the 
        /// WinChartViewer view port by dragging scrolling, or by zoom in/out, or the 
        /// WinChartViewer.updateViewPort method is being called.
        /// </summary>
        private void winChartViewer1_ViewPortChanged(object sender, WinViewPortEventArgs e)
        {
            // Compute the view port start date and duration
            DateTime currentStartDate = minDate.AddSeconds(Math.Round(winChartViewer1.ViewPortLeft * dateRange));
            currentDuration = Math.Round(winChartViewer1.ViewPortWidth * dateRange);

            // Synchronize the startDate and duration controls
            startDate.Value = currentStartDate;
            duration.Text = Math.Round(currentDuration / 86400).ToString();

            // Synchronize the horizontal scroll bar with the WinChartViewer
            hScrollBar1.Enabled = winChartViewer1.ViewPortWidth < 1;
            hScrollBar1.LargeChange = (int)Math.Ceiling(winChartViewer1.ViewPortWidth *
                (hScrollBar1.Maximum - hScrollBar1.Minimum));
            hScrollBar1.SmallChange = (int)Math.Ceiling(hScrollBar1.LargeChange * 0.1);
            hScrollBar1.Value = (int)Math.Round(winChartViewer1.ViewPortLeft *
                (hScrollBar1.Maximum - hScrollBar1.Minimum)) + hScrollBar1.Minimum;

            // Synchronize the vertical scroll bar with the WinChartViewer
            vScrollBar1.Enabled = winChartViewer1.ViewPortHeight < 1;
            vScrollBar1.LargeChange = (int)Math.Ceiling(winChartViewer1.ViewPortHeight *
                (vScrollBar1.Maximum - vScrollBar1.Minimum));
            vScrollBar1.SmallChange = (int)Math.Ceiling(vScrollBar1.LargeChange * 0.1);
            vScrollBar1.Value = (int)Math.Round(winChartViewer1.ViewPortTop *
                (vScrollBar1.Maximum - vScrollBar1.Minimum)) + vScrollBar1.Minimum;

            // Update chart and image map if necessary
            if (e.NeedUpdateChart)
                drawChart(winChartViewer1);
            if (e.NeedUpdateImageMap)
                updateImageMap(winChartViewer1);
        }

        /// <summary>
        /// Draw the chart.
        /// </summary>
        private void drawChart(WinChartViewer viewer)
        {
            //
            // In this demo, we copy the visible part of the data to a separate buffer for chart
            // plotting. 
            //
            // Note that if you only have a small amount of data (a few hundred data points), it
            // may be easier to just plot all data in any case (so the following copying code is 
            // not needed), and let ChartDirector "clip" the chart to the plot area. 
            //

            // Using ViewPortLeft and ViewPortWidth, get the start and end dates of the view port.
            DateTime viewPortStartDate = minDate.AddSeconds(Math.Round(viewer.ViewPortLeft * dateRange));
            DateTime viewPortEndDate = viewPortStartDate.AddSeconds(Math.Round(viewer.ViewPortWidth * dateRange));

            // Get the starting index of the array using the start date
            int startIndex = Array.BinarySearch(timeStamps, viewPortStartDate);
            if (startIndex < 0)
                startIndex = (~startIndex) - 1;

            // Get the ending index of the array using the end date
            int endIndex = Array.BinarySearch(timeStamps, viewPortEndDate);
            if (endIndex < 0)
                endIndex = ((~endIndex) < timeStamps.Length) ? ~endIndex : timeStamps.Length - 1;

            // Get the length
            int noOfPoints = endIndex - startIndex + 1;

            // Now, we can just copy the visible data we need into the view port data series
            DateTime[] viewPortTimeStamps = new DateTime[noOfPoints];
            double[] viewPortDataSeriesA = new double[noOfPoints];
            double[] viewPortDataSeriesB = new double[noOfPoints];
            double[] viewPortDataSeriesC = new double[noOfPoints];
            Array.Copy(timeStamps, startIndex, viewPortTimeStamps, 0, noOfPoints);
            Array.Copy(dataSeriesA, startIndex, viewPortDataSeriesA, 0, noOfPoints);
            Array.Copy(dataSeriesB, startIndex, viewPortDataSeriesB, 0, noOfPoints);
            Array.Copy(dataSeriesC, startIndex, viewPortDataSeriesC, 0, noOfPoints);

            if (viewPortTimeStamps.Length >= 520)
            {
                //
                // Zoomable chart with high zooming ratios often need to plot many thousands of 
                // points when fully zoomed out. However, it is usually not needed to plot more
                // data points than the resolution of the chart. Plotting too many points may cause
                // the points and the lines to overlap. So rather than increasing resolution, this 
                // reduces the clarity of the chart. So it is better to aggregate the data first if
                // there are too many points.
                //
                // In our current example, the chart only has 520 pixels in width and is using a 2
                // pixel line width. So if there are more than 520 data points, we aggregate the 
                // data using the ChartDirector aggregation utility method.
                //
                // If in your real application, you do not have too many data points, you may 
                // remove the following code altogether.
                //

                // Set up an aggregator to aggregate the data based on regular sized slots
                ArrayMath m = new ArrayMath(viewPortTimeStamps);
                m.selectRegularSpacing(viewPortTimeStamps.Length / 260);

                // For the timestamps, take the first timestamp on each slot
                viewPortTimeStamps = m.aggregate(viewPortTimeStamps, Chart.AggregateFirst);

                // For the data values, aggregate by taking the averages
                viewPortDataSeriesA = m.aggregate(viewPortDataSeriesA, Chart.AggregateAvg);
                viewPortDataSeriesB = m.aggregate(viewPortDataSeriesB, Chart.AggregateAvg);
                viewPortDataSeriesC = m.aggregate(viewPortDataSeriesC, Chart.AggregateAvg);
            }

            //
            // Now we have obtained the data, we can plot the chart. 
            //

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 1 - Configure overall chart appearance. 
            ///////////////////////////////////////////////////////////////////////////////////////

            // Create an XYChart object 600 x 300 pixels in size, with pale blue (0xf0f0ff) 
            // background, black (000000) border, 1 pixel raised effect, and with a rounded frame.
            XYChart c = new XYChart(600, 300, 0xf0f0ff, 0, 1);
            c.setRoundedFrame(Chart.CColor(BackColor));

            // Set the plotarea at (52, 60) and of size 520 x 192 pixels. Use white (ffffff) 
            // background. Enable both horizontal and vertical grids by setting their colors to 
            // grey (cccccc). Set clipping mode to clip the data lines to the plot area.
            c.setPlotArea(52, 60, 520, 192, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
            c.setClipping();

            // Add a top title to the chart using 15 pts Times New Roman Bold Italic font, with a 
            // light blue (ccccff) background, black (000000) border, and a glass like raised effect.
            c.addTitle("Zooming and Scrolling Demonstration", "Times New Roman Bold Italic", 15
                ).setBackground(0xccccff, 0x0, Chart.glassEffect());

            // Add a bottom title to the chart to show the date range of the axis, with a light blue 
            // (ccccff) background.
            c.addTitle2(Chart.Bottom, "From <*font=Arial Bold Italic*>"
                + c.formatValue(viewPortStartDate, "{value|mmm dd, yyyy}")
                + "<*/font*> to <*font=Arial Bold Italic*>"
                + c.formatValue(viewPortEndDate, "{value|mmm dd, yyyy}")
                + "<*/font*> (Duration <*font=Arial Bold Italic*>"
                + Math.Round(viewPortEndDate.Subtract(viewPortStartDate).TotalSeconds / 86400.0)
                + "<*/font*> days)", "Arial Italic", 10).setBackground(0xccccff);

            // Add a legend box at the top of the plot area with 9pts Arial Bold font with flow layout. 
            c.addLegend(50, 33, false, "Arial Bold", 9).setBackground(Chart.Transparent, Chart.Transparent);

            // Set axes width to 2 pixels
            c.yAxis().setWidth(2);
            c.xAxis().setWidth(2);

            // Add a title to the y-axis
            c.yAxis().setTitle("Price (USD)", "Arial Bold", 9);

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 2 - Add data to chart
            ///////////////////////////////////////////////////////////////////////////////////////

            // 
            // In this example, we represent the data by lines. You may modify the code below if 
            // you want to use other representations (areas, scatter plot, etc).
            //

            // Add a line layer for the lines, using a line width of 2 pixels
            Layer layer = c.addLineLayer2();
            layer.setLineWidth(2);

            // Now we add the 3 data series to a line layer, using the color red (ff0000), green
            // (00cc00) and blue (0000ff)
            layer.setXData(viewPortTimeStamps);
            layer.addDataSet(viewPortDataSeriesA, 0xff0000, "Product Alpha");
            layer.addDataSet(viewPortDataSeriesB, 0x00cc00, "Product Beta");
            layer.addDataSet(viewPortDataSeriesC, 0x0000ff, "Product Gamma");

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 3 - Set up x-axis scale
            ///////////////////////////////////////////////////////////////////////////////////////

            // Set x-axis date scale to the view port date range. 
            c.xAxis().setDateScale(viewPortStartDate, viewPortEndDate);

            //
            // In the current demo, the x-axis range can be from a few years to a few days. We can 
            // let ChartDirector auto-determine the date/time format. However, for more beautiful 
            // formatting, we set up several label formats to be applied at different conditions. 
            //

            // If all ticks are yearly aligned, then we use "yyyy" as the label format.
            c.xAxis().setFormatCondition("align", 360 * 86400);
            c.xAxis().setLabelFormat("{value|yyyy}");

            // If all ticks are monthly aligned, then we use "mmm yyyy" in bold font as the first 
            // label of a year, and "mmm" for other labels.
            c.xAxis().setFormatCondition("align", 30 * 86400);
            c.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "<*font=bold*>{value|mmm yyyy}",
                Chart.AllPassFilter(), "{value|mmm}");

            // If all ticks are daily algined, then we use "mmm dd<*br*>yyyy" in bold font as the 
            // first label of a year, and "mmm dd" in bold font as the first label of a month, and
            // "dd" for other labels.
            c.xAxis().setFormatCondition("align", 86400);
            c.xAxis().setMultiFormat(
                Chart.StartOfYearFilter(), "<*block,halign=left*><*font=bold*>{value|mmm dd<*br*>yyyy}",
                Chart.StartOfMonthFilter(), "<*font=bold*>{value|mmm dd}");
            c.xAxis().setMultiFormat2(Chart.AllPassFilter(), "{value|dd}");

            // For all other cases (sub-daily ticks), use "hh:nn<*br*>mmm dd" for the first label of
            // a day, and "hh:nn" for other labels.
            c.xAxis().setFormatCondition("else");
            c.xAxis().setMultiFormat(Chart.StartOfDayFilter(), "<*font=bold*>{value|hh:nn<*br*>mmm dd}",
                Chart.AllPassFilter(), "{value|hh:nn}");

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 4 - Set up y-axis scale
            ///////////////////////////////////////////////////////////////////////////////////////

            if ((viewer.ZoomDirection == WinChartDirection.Horizontal) || (minValue == maxValue))
            {
                // y-axis is auto-scaled - save the chosen y-axis scaled to support xy-zoom mode
                c.layout();
                minValue = c.yAxis().getMinValue();
                maxValue = c.yAxis().getMaxValue();
            }
            else
            {
                // xy-zoom mode - compute the actual axis scale in the view port 
                double axisLowerLimit = maxValue - (maxValue - minValue) * (viewer.ViewPortTop + viewer.ViewPortHeight);
                double axisUpperLimit = maxValue - (maxValue - minValue) * viewer.ViewPortTop;
                // *** use the following formula if you are using a log scale axis ***
                // double axisLowerLimit = maxValue * Math.Pow(minValue / maxValue, viewer.ViewPortTop + viewer.ViewPortHeight);
                // double axisUpperLimit = maxValue * Math.Pow(minValue / maxValue, viewer.ViewPortTop);

                // use the zoomed-in scale
                c.yAxis().setLinearScale(axisLowerLimit, axisUpperLimit);
                c.yAxis().setRounding(false, false);
            }

            ///////////////////////////////////////////////////////////////////////////////////////
            // Step 5 - Display the chart
            ///////////////////////////////////////////////////////////////////////////////////////

            viewer.Chart = c;
        }

        /// <summary>
        /// Update the image map used on the chart.
        /// </summary>
        private void updateImageMap(WinChartViewer viewer)
        {
            // Include tool tip for the chart
            if (winChartViewer1.ImageMap == null)
            {
                winChartViewer1.ImageMap = winChartViewer1.Chart.getHTMLImageMap("clickable", "",
                    "title='[{dataSetName}] {x|mmm dd, yyyy}: USD {value|2}'");
            }
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmZoomScrollDemo));
            this.topLabel = new System.Windows.Forms.Label();
            this.pointerPB = new System.Windows.Forms.RadioButton();
            this.zoomInPB = new System.Windows.Forms.RadioButton();
            this.zoomOutPB = new System.Windows.Forms.RadioButton();
            this.startDate = new System.Windows.Forms.DateTimePicker();
            this.duration = new System.Windows.Forms.ComboBox();
            this.startDateLabel = new System.Windows.Forms.Label();
            this.durationLabel = new System.Windows.Forms.Label();
            this.leftPanel = new System.Windows.Forms.Panel();
            this.separatorLine = new System.Windows.Forms.Label();
            this.zoomModePanel = new System.Windows.Forms.Panel();
            this.xZoomPB = new System.Windows.Forms.RadioButton();
            this.xyZoomPB = new System.Windows.Forms.RadioButton();
            this.zoomModeLabel = new System.Windows.Forms.Label();
            this.toolTip = new System.Windows.Forms.ToolTip(this.components);
            this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
            this.winChartViewer1 = new ChartDirector.WinChartViewer();
            this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
            this.filler = new System.Windows.Forms.Panel();
            this.leftPanel.SuspendLayout();
            this.zoomModePanel.SuspendLayout();
            this.SuspendLayout();
            // 
            // topLabel
            // 
            this.topLabel.BackColor = System.Drawing.Color.Navy;
            this.topLabel.Dock = System.Windows.Forms.DockStyle.Top;
            this.topLabel.Font = new System.Drawing.Font("Arial", 9.75F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.topLabel.ForeColor = System.Drawing.Color.Yellow;
            this.topLabel.Name = "topLabel";
            this.topLabel.Size = new System.Drawing.Size(750, 24);
            this.topLabel.TabIndex = 17;
            this.topLabel.Text = "Advanced Software Engineering";
            this.topLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // pointerPB
            // 
            this.pointerPB.Appearance = System.Windows.Forms.Appearance.Button;
            this.pointerPB.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.pointerPB.Image = ((System.Drawing.Bitmap)(resources.GetObject("pointerPB.Image")));
            this.pointerPB.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.pointerPB.Name = "pointerPB";
            this.pointerPB.Size = new System.Drawing.Size(120, 25);
            this.pointerPB.TabIndex = 0;
            this.pointerPB.Text = "      Pointer";
            this.toolTip.SetToolTip(this.pointerPB, "Click to display hot spot parameters.\nDrag to scroll.");
            this.pointerPB.CheckedChanged += new System.EventHandler(this.pointerPB_CheckedChanged);
            // 
            // zoomInPB
            // 
            this.zoomInPB.Appearance = System.Windows.Forms.Appearance.Button;
            this.zoomInPB.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.zoomInPB.Image = ((System.Drawing.Bitmap)(resources.GetObject("zoomInPB.Image")));
            this.zoomInPB.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.zoomInPB.Location = new System.Drawing.Point(0, 24);
            this.zoomInPB.Name = "zoomInPB";
            this.zoomInPB.Size = new System.Drawing.Size(120, 25);
            this.zoomInPB.TabIndex = 1;
            this.zoomInPB.Text = "      Zoom In";
            this.toolTip.SetToolTip(this.zoomInPB, "Click to zoom in.\nDrag to select zoom region.");
            this.zoomInPB.CheckedChanged += new System.EventHandler(this.zoomInPB_CheckedChanged);
            // 
            // zoomOutPB
            // 
            this.zoomOutPB.Appearance = System.Windows.Forms.Appearance.Button;
            this.zoomOutPB.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.zoomOutPB.Image = ((System.Drawing.Bitmap)(resources.GetObject("zoomOutPB.Image")));
            this.zoomOutPB.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.zoomOutPB.Location = new System.Drawing.Point(0, 48);
            this.zoomOutPB.Name = "zoomOutPB";
            this.zoomOutPB.Size = new System.Drawing.Size(120, 24);
            this.zoomOutPB.TabIndex = 2;
            this.zoomOutPB.Text = "      Zoom Out";
            this.toolTip.SetToolTip(this.zoomOutPB, "Click to zoom out.");
            this.zoomOutPB.CheckedChanged += new System.EventHandler(this.zoomOutPB_CheckedChanged);
            // 
            // startDate
            // 
            this.startDate.CustomFormat = "";
            this.startDate.Format = System.Windows.Forms.DateTimePickerFormat.Short;
            this.startDate.Location = new System.Drawing.Point(4, 184);
            this.startDate.Name = "startDate";
            this.startDate.Size = new System.Drawing.Size(112, 20);
            this.startDate.TabIndex = 5;
            this.toolTip.SetToolTip(this.startDate, "Starting date on the x-axis");
            this.startDate.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0);
            this.startDate.ValueChanged += new System.EventHandler(this.startDate_ValueChanged);
            // 
            // duration
            // 
            this.duration.ForeColor = System.Drawing.SystemColors.WindowText;
            this.duration.ItemHeight = 14;
            this.duration.Items.AddRange(new object[] {
														  "10",
														  "20",
														  "30",
														  "60",
														  "90",
														  "180",
														  "360",
														  "720",
														  "1080",
														  "1440"});
            this.duration.Location = new System.Drawing.Point(4, 236);
            this.duration.MaxDropDownItems = 12;
            this.duration.Name = "duration";
            this.duration.Size = new System.Drawing.Size(112, 22);
            this.duration.TabIndex = 6;
            this.duration.Text = "60";
            this.toolTip.SetToolTip(this.duration, "Duration of the x-axis");
            this.duration.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.duration_KeyPress);
            this.duration.SelectedIndexChanged += new System.EventHandler(this.duration_SelectedIndexChanged);
            this.duration.Leave += new System.EventHandler(this.duration_Leave);
            // 
            // startDateLabel
            // 
            this.startDateLabel.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.startDateLabel.Location = new System.Drawing.Point(4, 168);
            this.startDateLabel.Name = "startDateLabel";
            this.startDateLabel.Size = new System.Drawing.Size(72, 16);
            this.startDateLabel.TabIndex = 1;
            this.startDateLabel.Text = "Start Date";
            // 
            // durationLabel
            // 
            this.durationLabel.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.durationLabel.Location = new System.Drawing.Point(4, 220);
            this.durationLabel.Name = "durationLabel";
            this.durationLabel.Size = new System.Drawing.Size(96, 16);
            this.durationLabel.TabIndex = 12;
            this.durationLabel.Text = "Duration (Days)";
            // 
            // leftPanel
            // 
            this.leftPanel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
            this.leftPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.separatorLine,
																					this.zoomModePanel,
																					this.zoomModeLabel,
																					this.duration,
																					this.pointerPB,
																					this.zoomInPB,
																					this.zoomOutPB,
																					this.startDate,
																					this.startDateLabel,
																					this.durationLabel});
            this.leftPanel.Dock = System.Windows.Forms.DockStyle.Left;
            this.leftPanel.Location = new System.Drawing.Point(0, 24);
            this.leftPanel.Name = "leftPanel";
            this.leftPanel.Size = new System.Drawing.Size(120, 332);
            this.leftPanel.TabIndex = 18;
            // 
            // separatorLine
            // 
            this.separatorLine.BackColor = System.Drawing.Color.Black;
            this.separatorLine.Dock = System.Windows.Forms.DockStyle.Right;
            this.separatorLine.Location = new System.Drawing.Point(119, 0);
            this.separatorLine.Name = "separatorLine";
            this.separatorLine.Size = new System.Drawing.Size(1, 332);
            this.separatorLine.TabIndex = 31;
            // 
            // zoomModePanel
            // 
            this.zoomModePanel.Controls.AddRange(new System.Windows.Forms.Control[] {
																						this.xZoomPB,
																						this.xyZoomPB});
            this.zoomModePanel.Location = new System.Drawing.Point(0, 104);
            this.zoomModePanel.Name = "zoomModePanel";
            this.zoomModePanel.Size = new System.Drawing.Size(120, 52);
            this.zoomModePanel.TabIndex = 34;
            // 
            // xZoomPB
            // 
            this.xZoomPB.Appearance = System.Windows.Forms.Appearance.Button;
            this.xZoomPB.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.xZoomPB.Image = ((System.Drawing.Bitmap)(resources.GetObject("xZoomPB.Image")));
            this.xZoomPB.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.xZoomPB.Name = "xZoomPB";
            this.xZoomPB.Size = new System.Drawing.Size(120, 25);
            this.xZoomPB.TabIndex = 3;
            this.xZoomPB.Text = "      X Zoom / Y Auto";
            this.toolTip.SetToolTip(this.xZoomPB, "X-Axis zoomable / Y-Axis auto-scaled");
            this.xZoomPB.CheckedChanged += new System.EventHandler(this.xZoomPB_CheckedChanged);
            // 
            // xyZoomPB
            // 
            this.xyZoomPB.Appearance = System.Windows.Forms.Appearance.Button;
            this.xyZoomPB.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.xyZoomPB.Image = ((System.Drawing.Bitmap)(resources.GetObject("xyZoomPB.Image")));
            this.xyZoomPB.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.xyZoomPB.Location = new System.Drawing.Point(0, 24);
            this.xyZoomPB.Name = "xyZoomPB";
            this.xyZoomPB.Size = new System.Drawing.Size(120, 24);
            this.xyZoomPB.TabIndex = 4;
            this.xyZoomPB.Text = "      XY Zoom";
            this.toolTip.SetToolTip(this.xyZoomPB, "X-Axis and Y-Axis zoomable");
            this.xyZoomPB.CheckedChanged += new System.EventHandler(this.xyZoomPB_CheckedChanged);
            // 
            // zoomModeLabel
            // 
            this.zoomModeLabel.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.zoomModeLabel.Location = new System.Drawing.Point(4, 88);
            this.zoomModeLabel.Name = "zoomModeLabel";
            this.zoomModeLabel.Size = new System.Drawing.Size(92, 16);
            this.zoomModeLabel.TabIndex = 33;
            this.zoomModeLabel.Text = "Zoom Mode";
            // 
            // hScrollBar1
            // 
            this.hScrollBar1.BackColor = System.Drawing.Color.White;
            this.hScrollBar1.Cursor = System.Windows.Forms.Cursors.Default;
            this.hScrollBar1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.hScrollBar1.Location = new System.Drawing.Point(120, 340);
            this.hScrollBar1.Maximum = 1000000000;
            this.hScrollBar1.Name = "hScrollBar1";
            this.hScrollBar1.Size = new System.Drawing.Size(614, 16);
            this.hScrollBar1.TabIndex = 6;
            this.hScrollBar1.ValueChanged += new System.EventHandler(this.hScrollBar1_ValueChanged);
            // 
            // winChartViewer1
            // 
            this.winChartViewer1.ChartSizeMode = ChartDirector.WinChartSizeMode.StretchImage;
            this.winChartViewer1.HotSpotCursor = System.Windows.Forms.Cursors.Hand;
            this.winChartViewer1.Location = new System.Drawing.Point(128, 32);
            this.winChartViewer1.Name = "winChartViewer1";
            this.winChartViewer1.ScrollDirection = ChartDirector.WinChartDirection.HorizontalVertical;
            this.winChartViewer1.Size = new System.Drawing.Size(600, 300);
            this.winChartViewer1.TabIndex = 19;
            this.winChartViewer1.TabStop = false;
            this.winChartViewer1.ZoomDirection = ChartDirector.WinChartDirection.HorizontalVertical;
            this.winChartViewer1.ViewPortChanged += new ChartDirector.WinViewPortEventHandler(this.winChartViewer1_ViewPortChanged);
            this.winChartViewer1.MouseEnter += new System.EventHandler(this.winChartViewer1_MouseEnter);
            this.winChartViewer1.ClickHotSpot += new ChartDirector.WinHotSpotEventHandler(this.winChartViewer1_ClickHotSpot);
            // 
            // vScrollBar1
            // 
            this.vScrollBar1.Location = new System.Drawing.Point(734, 24);
            this.vScrollBar1.Maximum = 1000000000;
            this.vScrollBar1.Name = "vScrollBar1";
            this.vScrollBar1.Size = new System.Drawing.Size(16, 316);
            this.vScrollBar1.TabIndex = 20;
            this.vScrollBar1.ValueChanged += new System.EventHandler(this.vScrollBar1_ValueChanged);
            // 
            // filler
            // 
            this.filler.BackColor = System.Drawing.SystemColors.Control;
            this.filler.Location = new System.Drawing.Point(732, 340);
            this.filler.Name = "filler";
            this.filler.Size = new System.Drawing.Size(20, 16);
            this.filler.TabIndex = 21;
            // 
            // FrmZoomScrollDemo
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.BackColor = System.Drawing.Color.White;
            this.ClientSize = new System.Drawing.Size(750, 356);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.vScrollBar1,
																		  this.winChartViewer1,
																		  this.hScrollBar1,
																		  this.leftPanel,
																		  this.topLabel,
																		  this.filler});
            this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.Name = "FrmZoomScrollDemo";
            this.Text = "ChartDirector Zooming and Scrolling Demonstration";
            this.Load += new System.EventHandler(this.FrmZoomScrollDemo_Load);
            this.leftPanel.ResumeLayout(false);
            this.zoomModePanel.ResumeLayout(false);
            this.ResumeLayout(false);

        }
        #endregion

    }
}
